package com.example.aidemo.controller;

import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ollama")
public class OllamaController {

    @Autowired
    private OllamaChatModel ollamaChatModel;

    @GetMapping("/chat")
    public String chat(String userInput) {
        return this.ollamaChatModel.call(userInput);
    }

    @GetMapping(value = "stream",produces = "text/plain;charset=utf-8")
    Flux<String> stream(String userInput) {
        return this.ollamaChatModel.stream(userInput);
    }
}
